<?php
/**
 * huhaiqin，2023.03.28
 * 权限管理后台
 */
namespace Permission\Controller;
use Common\Controller\AdminBaseController;

class AdminController extends AdminBaseController{

    /**
     * huhaiqin,2023.03.28
     * 权限管理控制台
     */
    public function index(){
        $m = D('PermissionMenu');
        // $this->info = $m->_get_select_tree(70);
        $this->treedata = $m->_get_tree_array();
        $this->display();
    }

    /**
     * huhaiqin，2023.03.28
     * 添加、修改权限界面
     */
    public function edit(){
        C('LAYOUT_NAME','layout_layui');
        $m = D('PermissionMenu');
        $parentid = $_GET['parentid'] ? $_GET['parentid'] : 0;
        if($_GET['id']){
            $info = $m->find($_GET['id']);
            $parentid = $info['parentid'];
        }
        $this->info = $info;
        $this->select_str = $m->_get_select_tree($parentid);
        $this->display();
    }

    /**
     * huhaiqin，2023.03.28
     * 角色权限管理
     */
    public function role(){
        $this->display();
    }

    /**
     * huhaiqin，2023.03.28
     * 编辑角色权限
     */
    public function edit_role(){
        C('LAYOUT_NAME','layout_layui');
        if($_GET['id']){
            $info = D('PermissionRole')->find($_GET['id']);
            $this->info = $info;
        }
        $this->display();
    }

    /**
     * huhaiqin，2023.03.30
     * 权限分配
     */
    public function permission(){
        C('LAYOUT_NAME','layout_layui');
        $m = D('PermissionMenu');
        $this->treedata = $m->_get_tree_array();
        $this->check_menus = D('PermissionRoleMenu')->_get_menu_by_role_id($_GET['id']);
        $this->title = '分配权限';
        $this->display();
    }

}